package k3;


import java.awt.Color;
import java.awt.Graphics;
import java.util.ArrayList;

import javax.swing.JPanel;

public class Table extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private ArrayList<Shape> list = new ArrayList<Shape>();
	private int currentPoints = 0, unClicked = 0;
	public int getUnClicked() {
		return unClicked;
	}
	public void setUnClicked(int unClicked) {
		this.unClicked = unClicked;
	}
	private boolean over = false;
	public boolean isOver() {
		return over;
	}
	public void setOver(boolean over) {
		this.over = over;
	}
	public int getCurrentPoints() {
		return currentPoints;
	}
	public void setCurrentPoints(int currentPoints) {
		this.currentPoints = currentPoints;
	}
	public ArrayList<Shape> getList() {
		return list;
	}
	private int counter = 0;
	public int getCounter() {
		return counter;
	}
	public void setCounter(int counter) {
		this.counter = counter;
	}
	public void paintComponent(Graphics g){
		super.paintComponent(g);
		g.setColor(Color.BLUE);
		g.drawString("points: "+currentPoints, getWidth()-60, 20);
		
		if(over){
			for(Shape p : list){
				this.remove(p);
			}
			g.setColor(Color.RED);
			g.drawString("Game OVER! You got "+currentPoints+" points", getWidth()/2, getHeight()/2);
		}
		repaint();
	}
	
	public Table(int w, int h){
		this.setSize(w-10, h-10);
		this.setLayout(null);
		table();
	}
	private void table(){
		add("square");
		add("circle");
	}
	public void add(String s){
		Shape shape = new Shape(s, this);
		this.add(shape);
		counter++;
		list.add(shape);
	}
}
